//
//  ZXHomeCollectionViewCell.swift
//  loveBee
//
//  Created by zhangxing on 2017/8/13.
//  Copyright © 2017年 zhangXing. All rights reserved.
//

import UIKit

class ZXHomeCollectionViewCell: UICollectionViewCell {
    
    //homeCellViewModel用来接收从ZXHomeCollectionViewController传递过来的数据homeCellViewModel,这里接收到的数据homeCellViewModel是ZXHomeCellViewModel类型的,我们需要根据ZXHomeCellViewModel中的属性homeCellModel取出ZXHomeCellModel类型的数据,这样我们才能为控件属性赋值
    var homeCellViewModel: ZXHomeCellViewModel? {
        
        didSet {
            //我们在这里强制解包,将model变成不可选类型,因为这里能够获取的数据本来就是ZXHomeCellModel类型的
            let model = homeCellViewModel!.homeCellModel!
            
            //给图片赋值
            self.imageView.yy_setImage(with: URL.init(string: model.img!), placeholder: #imageLiteral(resourceName: "v2_placeholder_full_size"))
            
            
            //名字赋值
            nameLabel.text = model.name
            
            //超市价格赋值
            market_priceLabel.text = model.partner_price
            
            //原价赋值
            partner_priceLabel.text = model.market_price
            
            //规格赋值
            specificsLabel.text = model.specifics
            
            
        }
        
    }
    
    //图片
    @IBOutlet weak var imageView: UIImageView!
    
    //名字
    @IBOutlet weak var nameLabel: UILabel!
    //规格
    @IBOutlet weak var specificsLabel: UILabel!

    //超市价格
    @IBOutlet weak var market_priceLabel: UILabel!
    //原价
    @IBOutlet weak var partner_priceLabel: UILabel!
    
    //减号
    @IBOutlet weak var cutButton: UIButton!
    
    //加号
    @IBOutlet weak var addButton: UIButton!
    
    
    //数量
    @IBOutlet weak var countLabel: UILabel!
    
    //当我们自定义视图的时候,首先需要调用父类的
    override init(frame: CGRect) {
        super.init(frame: frame)
    }
    
    required init?(coder aDecoder: NSCoder) {
        //不支持xib
//        fatalError("init(coder:) has not been implemented")
        
        //支持xib
        super.init(coder: aDecoder)
    }

    
}
